# -*- coding: utf-8 -*-
from fastapi import APIRouter, Depends, Request, Response, UploadFile
from fastapi.security import OAuth2PasswordRequestForm
from loguru import logger

from app.api import jwt
from app.api.service import user_service
from app.api.service import role_service 
from app.common.pagination import Page
from app.common.response.response_schema import response_base
from app.models import User
from app.schemas.role import RQUpdateRole

role_router = APIRouter()


@role_router.get('/', description='查看所有的用户权限')
async def get_role(current_user: User = Depends(jwt.get_current_user)):
    res = await role_service.get_all_role()
    return response_base.response_200(msg='用户权限修改成功',data=res)
    


@role_router.put('/', description='修改用户权限')
async def put_role(obj:RQUpdateRole,current_user: User = Depends(jwt.get_current_is_admin_user)):
    await role_service.change_role(obj)
    return response_base.response_200(msg='用户权限修改成功')

 